#include <iostream>
#include <cmath>
#include <numeric>
#include <climits>

class Solution
{
public:
    int main()
    {
        int needCount;
        std::cin >> needCount;
        int needMoney = INT_MAX;
        for (int i = 0; i < 3; ++i)
        {
            int price, count;
            std::cin >> count >> price;
            int pack = static_cast<int>(ceil(1.0 * needCount / count));
            needMoney = std::min(needMoney, price * pack);
        }
        std::cout << needMoney;
        return 0;
    }
};

#ifndef __LOCAL_TEST__
int main()
{
    return Solution().main();
}
#endif